import { dateFormat } from '@/utils/date'

export const createColumns = (vm) => [
  {
    title: '',
    width: 34,
    align: 'center',
    type: 'selection',
  },
  {
    title: '序号',
    key: 'id',
    align: 'center',
    width: 80,
    render(h, params) {
      return <div>{(vm.formData.pageNo - 1) * vm.formData.pageSize + params.index + 1}</div>
    },
  },
  {
    title: '信息标题',
    width: 300,
    key: 'title',
    align: 'center',
    render(h, params) {
      return (
        <a href={params.row.url}>
          {params.row.title || ''}
        </a>
      )
    },
  },
  { title: '稿件来源', key: 'source', align: 'center' },
  {
    title: '热搜榜排名',
    key: 'rank',
    align: 'center',
    render(h, params) {
      return (
        <div class={['serial-rect', 'serial-rect' + (params.row.rank)]}>
          {/* {(vm.formData.pageNo - 1) * vm.formData.pageSize + params.index + 1} */}
          { params.row.rank }
        </div>
      )
    },
  },
  {
    title: '发布时间',
    key: 'publishTime',
    align: 'center',
    sortable: 'custom',
    render(h, params) {
      return <div>{dateFormat(params.row.publishTime || '', 'YYYY.MM.DD HH:mm:ss')}</div>
    },
  },
  {
    title: '入库时间',
    key: 'loadTime',
    align: 'center',
    sortable: 'custom',
    sortType: 'desc',
    render(h, params) {
      return <div>{dateFormat(params.row.loadTime || '', 'YYYY.MM.DD HH:mm:ss')}</div>
    },
  },
  {
    title: '操作',
    key: '',
    align: 'center',
    render(h, params) {
      return (
        <icon-button
          icon="enterPool"
          title="下发至稿池"
          disabled={params.row.pooling}
          nativeOnClick={() => {
            vm.enterPool(params.row)
          }}
        ></icon-button>
      )
    },
  },
]
